package com.peycard.persistence.dao;

import javax.ejb.Stateless;
import javax.persistence.Query;

import com.peycard.persistence.PersistenceException;
import com.peycard.persistence.dao.local.TokenPortalDAOLocal;
import com.peycard.persistence.entities.TokenPortal;

/**
 * Session Bean implementation class AsSysUserDAO
 */
@Stateless
public class TokenPortalDAO extends GenericDAOImpl<TokenPortal, Long> implements TokenPortalDAOLocal {

    /**
     * Default constructor. 
     */
    public TokenPortalDAO() {
        // TODO Auto-generated constructor stub
    }
    
    public TokenPortal getToken(Long idAdminSysUser) throws PersistenceException{
    	try{    		  						
			Query ftok = getEntityManager().createNamedQuery("findToken");
			ftok.setParameter("idAdminSysUser", idAdminSysUser);    		
			TokenPortal token = (TokenPortal) ftok.getSingleResult();
			return token;
    	}catch(Exception e){    		
    		throw new PersistenceException("Error en xx:"+e.getMessage(), e);
    	}		
    }

	
   
}
